package cn.gson.crm.controller;

import cn.gson.crm.model.pojos.*;
import cn.gson.crm.model.service.RepairOrderService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.*;

@Controller
@RequestMapping("/RepairOrderController")
public class RepairOrderController {
    @Autowired
    RepairOrderService repairOrderService;

    @RequestMapping("/ContractMethod")
    @ResponseBody
    //查询当前登录人维修工单的
    public Map<String,Object> selectrep(HttpSession session, Integer rid, Integer page, Integer size, String jinnian, String qunian, String qiannian){
        return repairOrderService.selectrep(session,rid,page,size,jinnian,qunian,qiannian);

    };
    @RequestMapping("/ContractMethod2")
    @ResponseBody
    //多条件查询维修记录
    public Map<String,Object> selectwhere(HttpSession session,Integer rid, String where,Integer page,Integer size){
        return repairOrderService.selectwhere(session,rid,where,page,size);
    };
    @RequestMapping("/ContractMethod3")
    @ResponseBody
    //时间查询维修记录
    public Map<String,Object> selecttime(HttpSession session,Integer rid,String statr,String endtime,Integer page,Integer size){
        return repairOrderService.selecttime(session,rid,statr,endtime,page,size);
    };
    @RequestMapping("/ContractMethod4")
    @ResponseBody
    //新增维修工单
    public void save(@RequestBody  RepairOrder repairOrder){
      repairOrderService.save(repairOrder);
    }

    @RequestMapping("/ContractMethod5")
    @ResponseBody
    //根据客户id查询此客户下所有订单
    public List<Order> selectorder(Integer cid){
        return repairOrderService.selectorder(cid);
    };
    @RequestMapping("/ContractMethod6")
    @ResponseBody
    //根据订单id查询订单详情
    public List<OrderDetails> selectodte(Integer odet){
        return repairOrderService.selectodte(odet);
    };
    @RequestMapping("/ContractMethod7")
    @ResponseBody
    //根据订单id查询订单详情
    public List<Linkman> selertqry(Integer ji){
        return repairOrderService.selectlinkman(ji);
    };
    @RequestMapping("/ContractMethod8")
    @ResponseBody
    //根据订单id查询订单详情
    public Map<String,Object> selectzong(HttpSession session,Integer cid){
        return repairOrderService.selectzonkong(session,cid);
    };

    @RequestMapping("/ContractMethod9")
    @ResponseBody
    public void  updatestate(String state,Integer rid){
        repairOrderService.updatestate(state,rid);
    }
    @RequestMapping("/ContractMethod10")
    @ResponseBody
    public void  updatweifou(Integer rid){
        repairOrderService.updatweifou(rid);
    }
    @RequestMapping("/ContractMethod11")
    @ResponseBody
    //详情
    public List<RepairOrderDetails> selectxian(Integer rid){
        return  repairOrderService.selectxian(rid);
    }
    @RequestMapping("/ContractMethod12")
    @ResponseBody
    //确认入库按钮改变维修入库状态未待入库
    public void updateweixx(String rukufou, Integer rid){
        repairOrderService.updateweixx(rukufou,rid);
    };
    //查询所有的维修记录和采购记录
    @RequestMapping("/ContractMethod13")
    @ResponseBody
    public List<Purchase> selectcaigou(){
        return  repairOrderService.selectcaigou();
    };
    @RequestMapping("/ContractMethod14")
    @ResponseBody
    public List<RepairOrder> selectweixiut(){
        return  repairOrderService.selectweixiut();
    };
}
